package com.mc.fastkit.view.shadow

import com.google.android.material.shape.MaterialShapeDrawable

/**
 * ShadowDrawable
 * @author: MasterChan
 * @date: 2025-05-06 16:55
 */
class ShadowDrawable : MaterialShapeDrawable() {

    private val onStateChangedListeners = mutableListOf<OnStateChangedListener>()

    fun interface OnStateChangedListener {
        fun onStateChanged(state: IntArray)
    }

    override fun onStateChange(state: IntArray): Boolean {
        onStateChangedListeners.forEach { it.onStateChanged(state) }
        return super.onStateChange(state)
    }

    fun setOnStateChangedListener(onStateChangedListener: OnStateChangedListener) {
        onStateChangedListeners.add(onStateChangedListener)
    }

    fun removeOnStateChangedListener(onStateChangedListener: OnStateChangedListener) {
        onStateChangedListeners.remove(onStateChangedListener)
    }
}